package com.xiaoshuidi.cloud.module.finance.controller.admin.collection;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.tenant.core.context.TenantContextHolder;
import com.xiaoshuidi.cloud.module.finance.controller.admin.collection.vo.FinanceCollectionConfigReqVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.collection.vo.FinanceCollectionConfigRespVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.finance.vo.account.FinanceAccountBalanceWarningReqVO;
import com.xiaoshuidi.cloud.module.finance.dal.dataobject.finance.FinanceAccountBalanceWarningDO;
import com.xiaoshuidi.cloud.module.finance.service.collection.FinanceCollectionConfigService;
import com.xiaoshuidi.cloud.module.finance.service.finance.FinanceAccountBalanceWarningService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

@Tag(name = "管理后台 - 收款配置")
@RestController
@RequestMapping("/finance/collection")
@Validated
public class FinanceCollectionConfigController {
    @Resource
    private FinanceCollectionConfigService financeCollectionConfigService;

    @GetMapping("/get")
    @Operation(summary = "根据门店获取配置")
    public CommonResult<FinanceCollectionConfigRespVO> get(@RequestParam("apartmentId") Long apartmentId) {
        return CommonResult.success(financeCollectionConfigService.get(apartmentId));
    }


    @PostMapping("/save")
    @Operation(summary = "保存门店收款配置")
    public CommonResult<Boolean> save(@Valid @RequestBody FinanceCollectionConfigReqVO financeCollectionConfigReqVO) {
        financeCollectionConfigService.save(financeCollectionConfigReqVO);
        return CommonResult.success(true);
    }
}
